import { _decorator } from 'cc';
import { BaseView } from '../../../scripts/libs/rxjs/cc3/BaseView';
import { Timer } from '../../../scripts/libs/rxjs/cc3/CreatorSchedule';
import { concat } from 'rxjs';
import { ResourceHelper } from '../../scripts/ResourceHelper';
import { ParticleSystem } from 'cc';
import { instantFunc } from '../../../scripts/libs/rxjs/cc3/CommonObservable';
const { ccclass, property } = _decorator;

@ccclass('Burst3')
export class Burst3 extends BaseView {

    onDestroyView(): void {
        this.node.clearSubscriptions();
    }

    burst() {
        this.node.clearSubscriptions();
        let ps = this.getComponent(ParticleSystem);
        ps.play();
        concat(
            Timer(.2, this.node),
            instantFunc(() => {
                ps.stopEmitting();
            }),
            Timer(1, this.node),
        ).subscribe({
            complete: () => {
                this.node.clearSubscriptions();
                ResourceHelper.Burst3Pool.putNode(this.node);
            }
        })
    }
}

